<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script src="../../js/jquery-3.3.1.min.js" charset="utf-8"></script>
    <link rel="stylesheet" href="/layui-v2.4.5/layui/css/layui.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<blockquote class="layui-elem-quote layui-text">
    添加代理商
</blockquote>

<%--<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">--%>
    <%--<legend>添加代理商</legend>--%>
<%--</fieldset>--%>

<form class="layui-form" id="myForm" action="###">
    <input type="hidden" name="id" value="${shop.id}">
    <div class="layui-form-item">
        <label class="layui-form-label">商户名称</label>
        <div class="layui-input-block">
            <input type="text" name="merchant_name"

                   value="${shop.merchant_name}"
                   lay-verify="title" autocomplete="off" placeholder="请输入商户名称" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-inline">
                <input type="tel" name="phone" value="${shop.phone}" lay-verify="required|phone" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">商户邮箱</label>
            <div class="layui-input-inline">
                <input type="text" name="email" value="${shop.emal}" lay-verify="email" autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-inline">
            <label class="layui-form-label">加入时间</label>
            <div class="layui-input-inline">
                <input type="text" name="enterTime" value="${shop.enterTime}" id="test1" lay-verify="test1" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-inline">
            <label class="layui-form-label">到期时间</label>
            <div class="layui-input-inline">
                <input type="text" name="endTime"  value="${shop.endTime}" id="test2" lay-verify="test2" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">客服电话</label>
            <div class="layui-input-inline">
                <input type="text" name="serviceTel" value="${shop.serviceTel}" lay-verify="required|number" autocomplete="off" class="layui-input">
            </div>
        </div>
        <%--<div class="layui-inline">--%>
            <%--<label class="layui-form-label">工作时间</label>--%>
            <%--<div class="layui-input-inline">--%>
                <%--<input type="text" name="workingTime" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">--%>
            <%--</div>--%>
        <%--</div>--%>



        <div class="layui-inline">
            <label class="layui-form-label">工作时间</label>
            <div class="layui-input-inline">
                <input type="text"  name="workingTime"  value="${shop.workingTime}" class="layui-input" id="test9" placeholder=" - ">
            </div>
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">商户地址</label>
        <div class="layui-input-block">
            <input type="text" name="adress" lay-verify="required" value="${shop.adress}"  placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">收费类型</label>
        <div class="layui-input-block">
            <select name="charges_type" lay-filter="aihao">
                <option value="按年" <c:if test="${shop.charges_type == '按年'}">selected="selected"</c:if> >按年</option>
                <option value="按单" <c:if test="${shop.charges_type == '按单'}">selected="selected"</c:if> >按单</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">每单提成</label>
        <div class="layui-input-block">
            <input type="text" name="per_commission" value="${shop.per_commission==null?0:shop.per_commission}" lay-verify="required|number" placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">公司简介</label>
        <div class="layui-input-block">
            <textarea name="synopsis" placeholder="请输入内容" class="layui-textarea">${synopsis}</textarea>
        </div>
    </div>
    <!--<div class="layui-form-item layui-form-text">
      <label class="layui-form-label">编辑器</label>
      <div class="layui-input-block">
        <textarea class="layui-textarea layui-hide" name="content" lay-verify="content" id="LAY_demo_editor"></textarea>
      </div>
    </div>-->
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>




<script src="/layui-v2.4.5/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });
        //日期时间选择器
        laydate.render({
            elem: '#test1'
            ,type: 'date'
        });
        //日期时间选择器
        laydate.render({
            elem: '#test2'
            ,type: 'date'
        });

        //时间范围
        laydate.render({
            elem: '#test9'
            ,type: 'time'
            ,range: true
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 5){
                    return '标题至少得5个字符啊';
                }
            }
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function(data){
            layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        //监听提交
        form.on('submit(demo1)', function(data){
            // layer.alert(JSON.stringify(data.field), {
            //     title: '最终的提交信息'
            // })
            // return false;

            $.ajax({
                url: '/shop/addShop',
                type: 'POST', //GET
                async: true,    //或false,是否异步
                data: $("#myForm").serialize(),
                timeout: 5000,    //超时时间
                dataType: 'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                beforeSend: function (xhr) {
                    /*console.log(xhr)
                     console.log('发送前')*/
                },
                success: function (data) {
                    console.log(data);
                    // if(data.result){
                        layer.msg("保存成功")
                        setTimeout(function () {
                            window.parent.location = window.parent.location.href
                        },1000)

                    // }else {
                    //     layer.msg("保存失败")
                    // }

                },
                error: function (xhr, textStatus) {
                    console.log('错误')
                    console.log(xhr)
                    console.log(textStatus)
                },
                complete: function () {
                    //console.log('结束')
                }
            });
            return false;//禁止跳转，否则会提交两次，且页面会刷新
        });


    });
</script>

</body>
</html>